<template>
	<div class="">
		<div class="crumbs">
			<h2 class="">讲师投诉管理</h2>
		</div>
		<div class="container ">
			<div class="handle-box margin-bottom20 row-me row-center">
				<el-form :model="query" label-width="80px" class="ipt row-me">
					<el-form-item label="模糊搜索">
						<el-input v-model="query.key" placeholder="请输入姓名、手机号"></el-input>
					</el-form-item>
				</el-form>

				<div class="margin-bottom20 margin-left20">
					<el-button type="primary" @click="handleSearch">查询</el-button>
					<el-button @click="resetClick">重置</el-button>
					<el-button type="primary" class="handle-del" @click="exportClick">批量导出</el-button>
				</div>
			</div>
			<el-table :data="tableData" border class="table" ref="multipleTable" header-cell-class-name="table-header"
				@selection-change="handleSelectionChange">
				<el-table-column type="selection" width="40" align="center"></el-table-column>
				<el-table-column prop="userName" label="反馈用户" align="center"></el-table-column>
				<el-table-column prop="phone" label="手机号" align="center"></el-table-column>
				<el-table-column prop="lecturerName" label="讲师昵称" align="center" show-overflow-tooltip></el-table-column>
				<el-table-column prop="lecturerPhone" label="讲师电话" align="center"></el-table-column>
				<el-table-column prop="userComment" label="反馈内容" align="center" show-overflow-tooltip></el-table-column>
				<el-table-column prop="createTime" label="反馈时间" align="center"></el-table-column>
			</el-table>
			<div class="pagination">
				<el-pagination background layout="total, prev, pager, next" :current-page="query.pageNumber"
					:page-size="query.pageSize" :total="pageTotal" @current-change="handlePageChange"></el-pagination>
			</div>
		</div>

	</div>
</template>

<script>
	export default {
		name: 'categoryTable',
		data() {
			return {
				query: {
					name: '',
					type: '',
					pageNumber: 1,
					pageSize: 30
				},
				dialogTitle: '',
				tableData: [],
				multipleSelection: [],
				editVisible: false,
				pageTotal: 0,
				form: {},
			};
		},
		created() {
			this.getData();
		},
		methods: {
			parseParams(data) {
				try {
					var tempArr = [];
					for (var i in data) {
						var key = encodeURIComponent(i);
						var value = encodeURIComponent(data[i]);
						tempArr.push(key + '=' + value);
					}
					var urlParamsStr = tempArr.join('&');
					return urlParamsStr;
				} catch (err) {
					return '';
				}
			},
			// 批量导出
			exportClick() {
				if (this.multipleSelection.length == 0) {
					this.$message.warning('请先选择数据!')
					return
				}

				var list = [];
				this.multipleSelection.forEach((item, index) => {
					list.push(item.id)
				});

				let params = {};
				// params.pageSize = 1000000000;
				// let appid = localStorage.getItem('htk_appid');
				params.token = localStorage.getItem('token');
				params.ids = list;
				window.open(this.$host + '/admin/lecturers/lecturerFeedbackExport?' + this.parseParams(params));
			},
			// 选择省区
			handleChange(value) {
				console.log(value);
			},
			// 获取 easy-mock 的模拟数据
			getData() {
				this.$postForm('/admin/lecturers/lecturerFeedbackAll', this.query).then((res) => {
					if (res.code == 1000) {
						this.tableData = res.data.list
						this.pageTotal = res.data.totalRow
					}
				}).catch((error) => {
					console.log(error)
				})

			},
			// 触发搜索按钮
			handleSearch() {
				this.$set(this.query, 'pageNumber', 1);
				this.getData();
			},
			// 点击重置
			resetClick() {
				this.query = {};
				this.$set(this.query, 'pageNumber', 1);
				this.getData();
			},
			// 多选操作
			handleSelectionChange(val) {
				this.multipleSelection = val;
			},
			// 编辑操作
			handleEdit(index, row) {
				this.title = '编辑排名';
				this.idx = index;
				this.form = row;
				this.rankingShow = true;
			},

			// 分页导航
			handlePageChange(val) {
				this.$set(this.query, 'pageNumber', val);
				this.getData();
			}
		}
	};
</script>

<style>
</style>